from common.sqlOperate import *
from common.writeExcel import *

host = '192.168.3.128'
# host = 'localhost'
port = 3306
user = 'test123'
password = 'test1234'
db='gwza0422'
ob = sqlOperate(host, port, user, password, db)
ob.sqlConnect()
df = pd.read_excel('./config/data.xls', sheet_name='410', header=0)
ids = df.values
# idslist = []
# for v in ids:
#     idslist.append(v[0])

t1 = '2024-05-16 12:00:00'  # 定义初始时间
t2 = '2024-05-16 14:00:00'  # 定义初始时间
list = []
list.append(['id','开始时间','结束时间','信号消失时长'])
for v in ids:
    result = ob.reqVltBehavior2(v[0],t1,t2)
    #print(result)
    for res in result:
        list.append([res[0],str(res[2]),str(res[1]),res[3]])

filename = 'result_test.xlsx'
we = writeExcel(filename)
ws = we.create_excel_sheet()
#输出 不好的数据的id
we.append_to_excel(list, ws)
we.save_to_excel()






